package com.example.exporttemplate.domain;

import javax.validation.constraints.Size;
import java.util.List;

/**
 * 章节
 *
 * @author liulindong
 * @version 2022/7/3 10:32
 */
public class Chapter {

    /**
     * name字段最大长度
     */
    private static final int nameMaxLength = 10;

    private String id;

    @Size(max = Chapter.nameMaxLength, message = "错啦错啦", groups = {POST.class})
    private String name;

    private String no;

    private Integer number;

    private int i;

    private double d;

    public int getI() {
        return i;
    }

    public void setI(int i) {
        this.i = i;
    }

    public double getD() {
        return d;
    }

    public void setD(double d) {
        this.d = d;
    }

    private List<Chapter> childrens;

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public List<Chapter> getChildrens() {
        return childrens;
    }

    public void setChildrens(List<Chapter> childrens) {
        this.childrens = childrens;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }


    public static void main(String[] args) {
        Chapter chapter = new Chapter();

        // 不空指针
        String no = chapter != null ? chapter.getNo() : "";

        // 不空指针
        Integer number = chapter != null ? null : 0;

        // 空指针
        Integer number1 = chapter != null ? chapter.getNumber() : 0;
    }
}
